<template>
  <nav class="bg-gradient-to-r from-blue-600 to-blue-800 text-white sticky top-0 z-50">
    <!-- 顶部导航条 -->
    <div class="container mx-auto px-2">
      <!-- 网站logo和主导航 -->
      <div class="flex items-center justify-between py-3">
        <!-- Logo -->
        <div class="flex items-center space-x-2">
          <i class="fa fa-code text-2xl"></i>
          <span class="text-xl font-bold">HTML5学习站</span>
        </div>
        
        <!-- 桌面导航 -->
        <div class="hidden md:flex space-x-4">
          <router-link to="/" class="nav-item nav-item-active">首页</router-link>
          <router-link to="/basics" class="nav-item">基础教程</router-link>
          <router-link to="/tags" class="nav-item">标签参考</router-link>
          <router-link to="/examples" class="nav-item">实例演示</router-link>
          <router-link to="/tools" class="nav-item">开发工具</router-link>
          <router-link to="/about" class="nav-item">关于我们</router-link>
        </div>
        
        <!-- 移动端菜单按钮 -->
        <button class="md:hidden p-2" @click="toggleMenu">
          <i class="fa fa-bars text-xl"></i>
        </button>
      </div>
      
      <!-- 移动端菜单 -->
      <div v-if="mobileMenuOpen" class="md:hidden bg-blue-700 py-2">
        <router-link to="/" class="block px-4 py-2 hover:bg-blue-600">首页</router-link>
        <router-link to="/basics" class="block px-4 py-2 hover:bg-blue-600">基础教程</router-link>
        <router-link to="/tags" class="block px-4 py-2 hover:bg-blue-600">标签参考</router-link>
        <router-link to="/examples" class="block px-4 py-2 hover:bg-blue-600">实例演示</router-link>
        <router-link to="/tools" class="block px-4 py-2 hover:bg-blue-600">开发工具</router-link>
        <router-link to="/about" class="block px-4 py-2 hover:bg-blue-600">关于我们</router-link>
      </div>
      
      <!-- 搜索框 -->
      <div class="md:flex items-center justify-center py-2 px-4 hidden">
        <div class="relative w-full max-w-md">
          <input 
            type="text" 
            placeholder="搜索HTML5教程、标签、实例..." 
            class="w-full px-4 py-2 rounded-l-md focus:outline-none text-gray-800"
          >
          <button class="absolute right-0 top-0 bg-blue-500 hover:bg-blue-400 text-white px-4 py-2 rounded-r-md">
            <i class="fa fa-search"></i>
          </button>
        </div>
      </div>
    </div>
  </nav>
</template>

<script>
export default {
  name: 'Html5Navbar',
  data() {
    return {
      mobileMenuOpen: false
    }
  },
  methods: {
    toggleMenu() {
      this.mobileMenuOpen = !this.mobileMenuOpen
    }
  }
}
</script>

<style scoped>
.nav-item {
  color: white;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.nav-item-active {
  background-color: rgba(255, 255, 255, 0.3);
  font-weight: bold;
}

/* 搜索框样式 */
input:focus {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}
</style>